package be.felnederlands.client.content.worddetail;

import be.felnederlands.client.content.GuiElementFactory;
import be.felnederlands.client.content.widgets.HPanel;
import be.felnederlands.client.data.Word;

import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Label;

public class WordDetailContent extends Composite {

	public WordDetailContent(Word word){
		FlowPanel row = new FlowPanel();

		row.add(createWordTitle(word));
		row.add(createDefinition(word));
		
		for (String example : word.getExamples()) {
			FlowPanel examplePanel = createExamplePanel(example);
			
			row.add(examplePanel);
		}
		
	}

	private FlowPanel createExamplePanel(String example) {
		FlowPanel examplePanel = GuiElementFactory.createSpan6Offset3FlowPanel();
		examplePanel.addStyleName("italic");
		examplePanel.add(new Label(example));
		return examplePanel;
	}

	private FlowPanel createDefinition(Word word) {
		FlowPanel definition = GuiElementFactory.createSpan6Offset3FlowPanel();
		definition.add(new Label(word.getDefinition()));
		return definition;
	}

	private FlowPanel createWordTitle(Word word) {
		FlowPanel wordTitle = GuiElementFactory.createSpan6Offset3FlowPanel();
		HPanel title = GuiElementFactory.createH2panelWithLabel(word.getWord());
		
		wordTitle.add(title);
		return wordTitle;
	}
	
}
